package com.cet.lxf.generic.test01;

import java.util.Arrays;

/**
 * @program: algorithm
 * @description:
 * @author: 陈恩涛
 * @create: 2021-08-02 09:49
 **/
public class Main01 {
    public static void main(String[] args) {
        Person[] ps = new Person[] {
                new Person("Bob", 61),
                new Person("Alice", 88),
                new Person("Lily", 75),
        };
        Arrays.sort(ps);
        System.out.println(Arrays.toString(ps));

    }
}

class Person implements Comparable<Person> {
    String name;
    int score;
    Person(String name, int score) {
        this.name = name;
        this.score = score;
    }

    @Override
    public String toString() {
        return this.name + "," + this.score;
    }

    @Override
    public int compareTo(Person other) {
        return name.compareTo(other.name);
    }
}
